<template>
<div class="app-container calendar-list-container">
  <div class="filter-container">
    <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="订单号" v-model="listQuery.orderSn"> </el-input>
    <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="收货人" v-model="listQuery.deliName"> </el-input>
    <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="收货人电话" v-model="listQuery.deliTel"> </el-input>
    <el-date-picker class="filter-item" v-model="dateRange" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" placeholder="下单时间">
    </el-date-picker>
    <el-button class="filter-item" type="primary" v-waves icon="search" @click="handleFilter">搜索</el-button>
  </div>
  <el-table :key='tableKey' :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%">
    <el-table-column align="center" label="订单号" min-width="10%"> <template scope="scope">
          <span>{{scope.row.orderSn}}</span>
        </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="商家"> <template scope="scope">
        <span>{{scope.row.shopName}}</span>
      </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="收货人名称"> <template scope="scope">
        <span>{{scope.row.deliName}}</span>
      </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="收货人电话"> <template scope="scope">
            <span>{{scope.row.deliTel}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="收货地址"> <template scope="scope">
            <span>{{scope.row.deliAddr}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="商品总价"> <template scope="scope">
            <span>{{scope.row.productAmount | currency('￥')}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="下单时间"> <template scope="scope">
            <span>{{scope.row.createTime}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="订单状态"> <template scope="scope">
            <span>{{scope.row.orderStatusName}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="支付状态"> <template scope="scope">
            <span>{{scope.row.payStatusName}}</span>
          </template> </el-table-column>
    <el-table-column min-width="10%" align="center" label="配送状态"> <template scope="scope">
            <span>{{scope.row.logisticsStatusName}}</span>
          </template> </el-table-column>
    <el-table-column align="center" label="操作" min-width="10%"> <template scope="scope">
        <el-button v-if="orderManager_btn_detail" size="small" type="success" @click="handleDetail(scope.row)">查看详情
        </el-button>
      </template> </el-table-column>
  </el-table>
  <div v-show="!listLoading" class="pagination-container">
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageNo" :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
  </div>
</div>
</template>

<script>
import {
  page,
  getObj
} from 'api/shop/order/order/index';
import { mapGetters } from 'vuex';
import {currency} from '@/utils/index';
export default {
  name: 'finishOrder',
  data() {
    return {
      list: null,
      total: null,
      dateRange : null,
      listLoading: true,
      listQuery: {
        pageNo: 1,
        pageSize: 20,
        orderSn: undefined,
        searchType:5,
        startTime : undefined,
        endTime : undefined,
        deliName:undefined,
        deliTel:undefined
      },
      orderManager_btn_detail:false,
      tableKey:0
    }
  },
  created() {
    this.getList();
    this.orderManager_btn_detail = this.elements['orderManager:btn_detail'];
  },
  filters:{
    currency: currency
  },
  computed: {
    ...mapGetters([
      'elements'
    ])
  },
  methods: {
    getList() {
      this.listLoading = true;
      page(this.listQuery)
        .then(response => {
          this.list = response.data.rows;
          this.total = response.data.total;
          this.listLoading = false;
        })
    },
    handleFilter() {
      if(this.dateRange != null){
        this.listQuery.startTime = this.dateRange[0];
        this.listQuery.endTime = this.dateRange[1];
      }
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNo = val;
      this.getList();
    },
    handleDetail(row) {
      this.$router.push({path: '/shop/order/orderDetail',query: {orderSn: row.orderSn}});
    }
  }
}
</script>
<style>
 
</style>